﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.IO;
using attendance.L3Bussobject;
using attendance.L2Busslogic;

namespace attendance.L4View.student
{
    public partial class student_register : System.Web.UI.Page
    {
        public static string ID;
        protected void Button1_Click(object sender, EventArgs e)
        {
            studentOB p = new studentOB();
            p = studentBL.Getwordsingle(TextBox1.Text.Trim());
            if (TextBox1.Text == p.name && TextBox2.Text == p.numb)
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('该用户已注册，请重新输入 ');</script>");
                TextBox1.Text = " ";
                TextBox2.Text = " ";
                return;
            }
            else
            {
                student_infoOB myword = new student_infoOB();
                myword = student_infoBL.Getwordsingle(TextBox1.Text.Trim());
                if (myword.name == TextBox1.Text && myword.numb == TextBox2.Text)
                {
                    studentOB mydd = new studentOB();
                    mydd.ID = ID;
                    mydd.name = TextBox1.Text;
                    mydd.numb = TextBox2.Text;
                    mydd.photo = " ";
                    Session["userName"] = this.TextBox1.Text;
                    if (!studentBL.Addfill(mydd))
                    {
                        Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('注册不成功 ');</script>");
                        return;
                    }
                    else
                    {
                        Response.Redirect("~/L4View/student/student_register_paizhao.aspx");
                        return;
                    }
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('与数据库中相应的信息不匹配，请重新输入 ');</script>");
                    TextBox1.Text = " ";
                    TextBox2.Text = " ";
                    return;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }
    }
}